#ifndef DATATREEMODEL_H
#define DATATREEMODEL_H


#include "model_global.h"
#include "abstractmodelitem.h"


#include <QAbstractItemModel>
#include <QPointer>


class MODELSHARED_EXPORT ItemTreeModel : public QAbstractItemModel
{
    Q_OBJECT

public:

    enum Role
    {
        Role_FIRST = Qt::UserRole + 1,

        Role_OBJECT_NAME = Role_FIRST,

        Role_LAST = Role_OBJECT_NAME
    };

    ItemTreeModel(QObject *parent = 0);
    ItemTreeModel(AbstractModelItem* root, QObject* parent = 0);

    void setRoot(AbstractModelItem* root);
    AbstractModelItem* root() const;

    static AbstractModelItem* itemFromIndex(const QModelIndex& index);

    virtual QModelIndex index(int row, int column, const QModelIndex &parent) const;
    virtual QModelIndex parent(const QModelIndex &child) const;

    virtual int rowCount(const QModelIndex &parent) const;
    virtual int columnCount(const QModelIndex &parent) const;

    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);


protected:

    QPointer<AbstractModelItem> m_root;


};



#endif // DATATREEMODEL_H


